define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'goodscommon/goodscommon/index',
                    add_url: 'goodscommon/goodscommon/add',
                    edit_url: 'goodscommon/goodscommon/edit',
                    del_url: 'goodscommon/goodscommon/del',
                    multi_url: 'goodscommon/goodscommon/multi',
                    table: 'goodscommon',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'pic', title: __('Pic'),formatter: Table.api.formatter.image},
                        {field: 'store.store_name', title: __('Store_id')},
                        {field: 'names', title: __('Names')},
                        {field: 'keyword', title: __('Keyword')},
                    /*    {field: 'classes_id', title: __('Classes_id')},*/
                        {field: 'classes_name', title: __('Classes_name')},
                        {field: 'goods_jingle', title: __('Goods_jingle')},
                       /* {field: 'goods_attr_index_ids', title: __('Goods_attr_index_ids')},
                        {field: 'spec_value_ids', title: __('Spec_value_ids')},*/

                        /*{field: 'sort', title: __('Sort')},*/
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')},visible:false},
                        {field: 'status_text', title: __('Status'),operate:false},
                        {field: 'reason', title: __('Reason')},
                        {field: 'goods_verify', title: __('Goods_verify'), searchList: {"1":__('Goods_verify 1'),"2":__('Goods_verify 2'),"3":__('Goods_verify 3')}, formatter: Table.api.formatter.normal,visible:false},
                        {field: 'goods_verify_text', title: __('Goods_verify'), operate:false,searchList: {"1":__('Goods_verify 1'),"2":__('Goods_verify 2'),"3":__('Goods_verify 3')}, formatter: Table.api.formatter.normal},
                        /*   {field: 'deletetime', title: __('Deletetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                                               */{field: 'goods_verifyremark', title: __('Goods_verifyremark')},
                      //  {field: 'money', title: __('Money'), operate:'BETWEEN'},
                        {field: 'price', title: __('原价'), operate:'BETWEEN'},
                        {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
                        {field: 'storage', title: __('Storage')},
                        /*{field: 'sale', title: __('Sale')},*/
                        /*{field: 'types', title: __('Types')},*/
                        {field: 'is_recomment', title: __('Is_recomment'), visible:false,searchList: {"1":__('Is_recomment 1'),"2":__('Is_recomment 2')}, formatter: Table.api.formatter.normal},
                        {field: 'is_recomment_text', title: __('Is_recomment'),operate:false, searchList: {"1":__('Is_recomment 1'),"2":__('Is_recomment 2')}, formatter: Table.api.formatter.normal},

                        /*  {field: 'goods_commend', title: __('Goods_commend')},*/
                        {field: 'source', title: __('Source'), visible:false,searchList: {"1":__('Source 1'),"2":__('Source 2')}, formatter: Table.api.formatter.normal},
                        {field: 'source_text', title: __('Source'), operate:false,searchList: {"1":__('Source 1'),"2":__('Source 2')}, formatter: Table.api.formatter.normal},

                        /*  {field: 'judge_count', title: __('Judge_count')},*/
                      /*  {field: 'postage', title: __('Postage'), operate:'BETWEEN'},*/
                     /*   {field: 'is_has_goods', title: __('Is_has_goods')},*/
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'operate', title: __('Operate'), table: table, buttons: [

                                {
                                    name: 'sku',
                                    text: '查看商品SKU',
                                    title: '查看商品SKU',
                                    icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    url: 'goods/goods/index'
                                },
                                {
                                    name: 'banner',
                                    text: '查看轮播图',
                                    title: '查看轮播图',
                                    icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    url: 'goods/goodspic/index'
                                },
                             /*   {
                                    name: 'addpic',
                                    text: '添加轮播图',
                                    title: '添加轮播图',
                                    icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    url: 'goods/goodspic/add'
                                }*/], events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        sku: function () {
            Controller.api.bindevent();
        },
        banner: function () {
            Controller.api.bindevent();
        },
        addpic: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});